package com.barneyx.mshinfoplatform.web.common;

import com.barneyx.mshinfoplatform.common.SmsUtil;
import com.barneyx.mshinfoplatform.common.ExResult;
import com.barneyx.mshinfoplatform.exception.SmsException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/sms/")
public class SmsController {

    @Resource
    private SmsUtil smsUtil;


    @GetMapping("/get-bind-code")
    public ExResult SendSms(@RequestParam("phone") String phone) throws SmsException {
        return ExResult.ofAuto(smsUtil.sendVerificationBindPhoneCode(phone), "发送成功,验证码有效期半小时!", "发送失败,请重新尝试", true);
    }
}
